package com.shujia.dwd

import com.shujia.commom.SparkTool
import org.apache.spark.sql.{DataFrame, SparkSession}

object DwdGsjRegLegrepreMskDay extends SparkTool {
  /**
   * 抽象方法: 在子类中实现这个方法
   * import spark.implicits._
   * import org.apache.spark.sql.functions._
   *
   * @param spark ：spark环境
   * @param ds    ：分区
   */
  override def run(spark: SparkSession, ds: String): Unit = {
    import spark.implicits._
    import org.apache.spark.sql.functions._

    /**
     * 读取hive中的表
     *
     */
    val legrepre: DataFrame = spark
      .table("ods.ods_t_gsj_reg_legrepre")
      .where($"ds" === ds)

    val resultDF: DataFrame = legrepre
      .select(
        upper(md5($"id")) as "id",
        $"position",
        upper(md5($"tel")) as "tel",
        $"appounit",
        $"accdside",
        $"posbrmode",
        $"offhfrom",
        $"offhto"
      )

    //保存数据
    save(resultDF,s"/daas/motl/dwd/dwd_gsj_reg_legrepre_msk_d/ds=$ds")
  }
}
